var backgroundLoggingFeature; // shorthand for logging to the console 
//without having to type the whole attribute name : chrome.extension.getBackgroundPage().console.log(xxx)

/////////////////////////////////// INITIALIZATION



$(document).ready(function () {    
    
    backgroundLoggingFeature=chrome.extension.getBackgroundPage().console;
    
    backgroundLoggingFeature.log("popup.js: initializated.. ");        
    
    $("#selectTest").bind("change", null, function() {
        browseToLab();
        
    });
    
    
    $("#selectTest option[value='2']").attr("selected", "selected");
    
    $("#selectTest").change();
    
    
    
    
});

function browseToLab() {
    var selectedLabUrl="html/popupDefaultFrame.html"; //default
    
    switch ($("#selectTest :selected").val()) {
        case "0":
            selectedLabUrl="html/labMessagePassing.html";
            break;
        case "1":
            selectedLabUrl="html/labJqueryLocal.html";
            break;
        case "2":
            selectedLabUrl="html/labJSONFeeds.html";
            break;
    }
    
    backgroundLoggingFeature.log("popup.js: changing test to "+selectedLabUrl);
    $("#labFrame").attr("src",selectedLabUrl);
}
function testUrlFromContentScript() {
    //    backgroundLoggingFeature.log("main.js: "+$(location).attr('href'));
    
    //    chrome.tabs.executeScript(null,
    //      {code:"document.body.style.backgroundColor='red';"});
    //{file:"scripts/content-script.js", "scripts/jquery-1.5.2.js"});


    chrome.tabs.executeScript(null, {
        file: "scripts/jquery-1.5.2.js"
    }, function(){
        chrome.tabs.executeScript(null, {
            file: "scripts/content-script.js"
        });
    });
// thanks goes to serg for the code above
// http://stackoverflow.com/questions/4976996/chromes-tabs-executescript-passing-parameters-and-using-libraries

}
//chrome.extension.getBackgroundPage().console.log("huh?");
//it's not the same console that's being used as that of the current page you're browsing, nor the popup one.
//it's the background.html one .
//http://groups.google.com/a/chromium.org/group/chromium-extensions/browse_thread/thread/fbf70bc0e6a56bfc/f087a504a19561d4